//
//  main.m
//  04-集合（二）
//
//  Created by dllo on 16/7/7.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Contact.h"
#import "ContactManager.h"

int main(int argc, const char * argv[]) {
   //1.字典
//    存储键值对（key-value）的集合类型，字典无序，通过key值存储，查询value
    //初始化
//    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:@"三丰",@"name", nil];
//    //构造器
//    NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"法王",@"name",[NSNumber numberWithInt:98],@"age", nil];
//    
//    //字面量
//    NSDictionary *diction = @{@"name":@"一波",@"age":@(16)};
//    
//    NSDictionary *diction1 = @{@"name":@"卫平",@"age":@(34)};
//    //字典中只能存放对象类型
//    
//    
//     NSString *name = [diction objectForKey:@"name"];//通过key取value
//    NSArray *allKeys =  diction.allKeys;
//    NSArray *allValues = diction.allValues;
////    NSLog(@"%@",allKeys);
//    NSLog(@"%@",allValues);
//    NSUInteger count = dic.count;
////    NSLog(@"%ld",count);
//    NSArray *allValueArray = [diction objectsForKeys:diction.allKeys notFoundMarker:[NSString class]];//通过一个数组，取到对应数组的value
////    NSLog(@"%@",allValueArray);
//    NSArray *array = [diction allKeysForObject:@(16)];//通过一个对象查找所有value是这个对象的所有key值
////    NSLog(@"%@",array);
//    
//    
////    NSLog(@"%@", diction[@"name"]);//语法糖取value
//    //初始化方式（不推荐使用字面量）与不可变字典基本相同
//    NSMutableDictionary *mutableDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"金子",@"name", nil];
//    NSMutableDictionary *mutableDiction = [@{} mutableCopy];
//    
//    
//    [mutableDic setObject:@"去欧尚的" forKey:@"name"];//如果key不存在，会直接添加，如果key存在，会将之前的value覆盖，字典中key不要重复，如果重复，会议最后的value进行赋值
//    NSLog(@"%@",mutableDic);
//    
//    
//    [mutableDic removeObjectForKey:@"name"];
//    [mutableDic removeAllObjects];
//    [mutableDic removeObjectsForKeys:@[@"name"]];
//    NSLog(@"%@",mutableDic);
//    mutableDic[@"name"] = @"李嘉诚";//语法糖
//    
//
//
    

    
//    
//    Contact *contact1 = [[Contact alloc] initWithName:@"zhongshan" phoneNumber:@"110"];
//    contact1.groupName = @"S";
//    contact1.address = @"孙菜园子";
//    contact1.age = 12;
//    contact1.sex = @"男";
//    
//    Contact *contact2 = [[Contact alloc] initWithName:@"fg" phoneNumber:@"111"];
//    
//    
//    
////    [contact showContact];
//    NSMutableDictionary *contactDictionary = [NSMutableDictionary dictionary];
//    ContactManager *contactManager = [[ContactManager alloc] initWithDictionary:contactDictionary];
   
//    [contactManager addContact:contact2];
    
//    NSLog(@"%@",contact.address);
//    NSLog(@"%@",contact);
//    NSMutableDictionary *contactDictionary = [NSMutableDictionary dictionary];
//    NSLog(@"%@",contactDictionary);
//    if (contact.name.length > 0 && contact.phoneNumber.length > 0) {
//        NSMutableArray *contactArr = [contactDictionary objectForKey:contact.groupName];
//        if (contactArr == nil) {
//            contactArr = [NSMutableArray array];
//            [contactArr addObject:contact];
//            [contactDictionary setObject:contactArr forKey:contact.groupName];
//        }else
//        {
//            [contactArr addObject:contact];
//            [contactDictionary setObject:contactArr forKey:contact.groupName];
//        }
//        NSLog(@"%@",contact);
//    
//    }else
//    {
//        NSLog(@"添加失败");
//    }
//    
//    NSMutableDictionary *contactDictionary = [NSMutableDictionary dictionary];
//    ContactManager *contactManager = [[ContactManager alloc] initWithDictionary:contactDictionary];

    
    
    
    
//    NSLog(@"%@",contactManager.contactDictionary);
//
    
    
//    NSSet *set = [[NSSet alloc] initWithObjects:@"sd",@"sd",nil];
////    NSLog(@"%@",set);//集合会删除重复的内容
//    
//    //构造器
//    NSSet *setObject = [NSSet setWithObjects:@"ff", @"ff",nil];
//    
//    //从集合中取出任意元素
//    [set anyObject];
//    NSUInteger setCount = set.count;
//    NSArray *repeatArray = @[@10,@20,@10,@30,@100];
//    NSSet *repeatSet = [NSSet setWithArray:repeatArray];
//    NSLog(@"%@",repeatSet);
//    
//    repeatArray = repeatSet.allObjects;
//    
//    //可变集合NSMutableSet
//    NSMutableSet *mutableSet = [NSMutableSet set];
//    [mutableSet addObject:@"123"];
//    [mutableSet removeObject: @"123"];
//    [mutableSet removeAllObjects];

    NSMutableArray *arr = [NSMutableArray array];
    NSString *str = [NSString stringWithFormat:@"sfsd"];
    [arr addObject:str];//可变数组独有的方法，不可变数组不能用
    NSLog(@"%@",arr);
    int a = 10;
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:@"f" forKey:@"df"];//可变字典独有方法，不可变字典不能用，值和建不能是基本数据类型（int）
     NSLog(@"%@",dic);
    

    return 0;
}
